﻿using System;
using System.Web.Mvc;

namespace DevExpress.Web.Demos {
    public partial class AccessibilityController : DemoController {
        [HttpGet]
        public ActionResult Compliance() {
            Session["EnableAccessibilityCompliant"] = true;
            return DemoView("Compliance", NorthwindDataProvider.GetEditableEmployees());
        }
        [HttpPost]
        public ActionResult Compliance(bool enableAccessibilityCompliant) {
            Session["EnableAccessibilityCompliant"] = enableAccessibilityCompliant;
            return DemoView("Compliance", NorthwindDataProvider.GetEditableEmployees());
        }
        public ActionResult CompliancePartial() {
            return PartialView("CompliancePartial", NorthwindDataProvider.GetEditableEmployees());
        }
        [HttpPost]
        public ActionResult ComplianceUpdatePartial(EditableEmployee employee) {
            if(ModelState.IsValid) {
                try {
                    NorthwindDataProvider.UpdateEditableEmployee(employee);
                }
                catch(Exception e) {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
                ViewData["EditError"] = "Please, correct all errors.";
            return PartialView("CompliancePartial", NorthwindDataProvider.GetEditableEmployees());
        }
    }
}
